package com.base.system.exception;

import com.base.system.enums.HttpStatus;
import lombok.Data;

@Data
public class HttpException extends RuntimeException {

    private static final long serialVersionUID = -3986488786662196534L;
    private HttpStatus httpStatus;
    private Integer code;
    private String msg;

    public HttpException() {
        super("服务器开小差了");
        httpStatus = HttpStatus.bad_error;
        msg = "服务器开小差了";
    }

    public HttpException(HttpStatus httpStatus) {
        super(httpStatus.getNote());
        this.httpStatus = httpStatus;
        code = httpStatus.getCode();
        msg = httpStatus.getNote();
    }

    public HttpException(String msg) {
        super(msg);
        this.msg = msg;
        code = HttpStatus.bad_error.getCode();
        httpStatus = HttpStatus.bad_error;
    }

    public HttpException(HttpStatus httpStatus,String msg){
        super(msg);
        this.httpStatus = httpStatus;
        code = httpStatus.getCode();
        this.msg = msg;
    }
}
